package com.jhws.business.appconfig.controller;

import com.jhws.common.base.bo.JsonRespData;
import com.jhws.business.appconfig.bo.AppConfigInfo;
import com.jhws.business.appconfig.service.AppConfigInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 配置信息控制器
 */
@Controller
@RequestMapping("/appConfig/info")
public class AppConfigInfoController {
    @Resource
    private AppConfigInfoService appConfigInfoService;

    /**
     * 保存配置
     *
     * @param appConfigInfo 配置信息
     */
    @RequestMapping("saveAppConfigInfo.x")
    @ResponseBody
    public JsonRespData saveAppConfigInfo(AppConfigInfo appConfigInfo) throws Exception {
        appConfigInfoService.save(appConfigInfo);
        return new JsonRespData("", 1, "添加配置成功");
    }


    /**
     * 分页查询配置信息
     *
     * @param deviceType 设备类型
     * @return 配置信息列表
     */
    @RequestMapping("queryAppConfigInfoPage.x")
    @ResponseBody
    public JsonRespData queryAppConfigInfoPage(String deviceType) {
        Map data = appConfigInfoService.queryAppConfigInfoPage(deviceType);
        return new JsonRespData("", 1, data);
    }

    /**
     * 删除配置信息
     *
     * @param appConfigInfo 配置信息ID
     */
    @RequestMapping("deleteAppConfigInfo.x")
    @ResponseBody
    public JsonRespData deleteAppConfigInfo(AppConfigInfo appConfigInfo) throws Exception {
        appConfigInfoService.deleteAppConfigInfo(appConfigInfo);
        return new JsonRespData("", 1, "删除成功");
    }
}
